import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './css/global.css'
import './assets/fonts/iconfont.css'
import TreeTable from 'vue-table-with-tree-grid'
//网页编辑器
import VueQuillEditor from 'vue-quill-editor'
// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import BMap from 'vue-baidu-map'
import axios from 'axios'
import store from './store/index.js'
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'  //本机上没有配置后台的数据接口 但是如果配置了的话就是在这里将根路径写上
//在request中 展示进度条   
//(当使用数据请求的时候就会调用nprogress,但是有时想只在切换路由的时候有进度条，就可以在index.js中的beforeEach和afterEach中加上)
axios.interceptors.request.use((config)=>{
  NProgress.start();
  console.log(config);
  //将token绑定在请求数据的头部，这样服务器可以有选择的返回数据，只对有效的请求返回数据
  config.headers.Authorization = window.sessionStorage.getItem("token");
  return config;
})
//在response中 展示进度条
axios.interceptors.response.use(config =>{
  NProgress.done();
  return config;
})
Vue.prototype.$http = axios;  //$http

Vue.config.productionTip = false
Vue.component('tree-table',TreeTable)
Vue.use(VueQuillEditor, /* { default global options } */)
// 引入百度地图
Vue.use(BMap, {
  ak: 'QCwVUReESxmUhW5uxYowhxjv8CRgti0t'
})
Vue.filter('dateFormat',function(origin){
  const dt = new Date(origin);
  var Y = dt.getFullYear();
  var M = (dt.getMonth()+1+'').padStart(2,'0');
  var D = (dt.getDate()+'').padStart(2,'0');
  var H = (dt.getHours()+'').padStart(2,'0');
  var Min = (dt.getMinutes()+'').padStart(2,'0');
  var s = (dt.getSeconds()+'').padStart(2,'0');

  return `${Y}-${M}-${D} ${H}:${Min}:${s}`
})

new Vue({
  router,
  render: h => h(App),
  store

}).$mount('#app')
